Easy2Siksha.com
cursor.execute("INSERT INTO Menu VALUES (103, 'Sandwich', 150)")
cursor.execute("INSERT INTO Orders VALUES (1, 1, 101, '2025-09-10')")
cursor.execute("INSERT INTO Orders VALUES (2, 2, 102, '2025-09-10')")
cursor.execute("INSERT INTO Orders VALUES (3, 1, 103, '2025-09-11')")
conn.commit()
# Step 4: Query with JOIN to combine data from multiple tables
cursor.execute("""
SELECT Orders.Order_ID, Customer.Name, Menu.Item_Name, Menu.Price,
Orders.Date
FROM Orders
JOIN Customer ON Orders.Customer_ID = Customer.Customer_ID
JOIN Menu ON Orders.Item_ID = Menu.Item_ID
""")
for row in cursor.fetchall():
print(row)
conn.close()
Output:
(1, 'Rajesh', 'Coffee', 100, '2025-09-10')
(2, 'Meena', 'Tea', 50, '2025-09-10')
(3, 'Rajesh', 'Sandwich', 150, '2025-09-11')
This shows how powerful multiple tables are. With just one query, you can see the full
picture: who ordered what and when.
Why Multiple Tables Matter
• No repetition → Rajesh’s details are written once in the Customer table.
• Flexibility → Adding a new dish doesn’t mess up old data.
• Accuracy → If Rajesh changes his phone, you update it in one place.
• Easy relationships → You can easily see links between customers, orders, and menu
items.
So, programming with multiple tables is like organizing your café with separate ledgers for
customers, menu, and orders. Everything is clean, efficient, and easy to manage.
(b) Data Modelling
Now, let’s go one step further. Before you even create those tables in your café’s database,
you need a blueprint. Just like an architect draws a design before building a house, in
databases, we use data modelling to design the structure of data.